package mapper.entity;

import server.HttpServlet;

import java.util.List;

/**
 * Created by Ju·Felix on 2020/5/17.
 */
public class Host {

    private String name;
    private List<Context> contextList;

    public Host() {
    }

    public Host(String name, List<Context> contextList) {
        this.name = name;
        this.contextList = contextList;
    }

    public HttpServlet findHttpServlet(String contextName, String urlPattern) {
        // 第二层：过滤context
        for (Context context : contextList) {
            if (context.getName().equals(contextName)) {
                return context.findHttpServlet(urlPattern);
            }
        }
        return null;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public List<Context> getContextList() {
        return contextList;
    }

    public void setContextList(List<Context> contextList) {
        this.contextList = contextList;
    }

}
